
<?php
	@session_start();
	// thao tác tới bang sách mới
	$sql = "select * from book ";
	$sql .= " where idCategory = 20";
	$sach_moi = select_list($sql);
	
	//thao tác tới bảng sách đọc nhiều
	$sql = "select * from book ";
	$sql.="order by ViewNumber DESC limit 6";
	$sach_doc_nhieu = select_list($sql);
	
	/******************tính tổng tiền**************/
	 $tongtien1=0;
	if(isset($_SESSION['giohang']))
	{
	
		for($i=0; $i<count($_SESSION['giohang']);$i++)
		{
			$query=("select * from book where idBook=".$_SESSION['giohang'][$i]['idBook']);
			$menu_left1 = select_list($query);	
			
			if($menu_left1) foreach ($menu_left1 as $row){
				$tongtien1=$tongtien1+ $row['SalePrice']*$_SESSION['giohang'][$i]['soluong'];
				$tongtien =number_format($tongtien1, 0, ',', ' ');
				
				if(isset($_SESSION['tongtien']))
				{
					$_SESSION['tongtien']= $tongtien;
				}
				else  $_SESSION['tongtien']=0;
			}
		}
	}
	
	
	
?>

	<div class="gio-hang">
						Giỏ Hàng
						</div>
                        <div class="phan1">
                        	</br><h4>Trong giỏ hàng: <span class="gia-ban">
							<?php if(isset($_SESSION['giohang'])) echo count( $_SESSION['giohang']); 
							else echo 0;
							 //in ra phần số lượng hàng có trong giỏ hàng?> 
							 </span> sản phẩm</h4>
                            <h4>Tổng tiền:<span class="gia-ban" style="padding-left:36px;">  
							
							 <?php 
							 if(isset($_SESSION['tongtien']))
							{
								echo ($_SESSION['tongtien']);
							}
							else
							echo 0;
							?> d</span></h4>
							
							<a class="btnMuaSp" title="Giỏ hàng" href="cart.php"></a>
							<a id="button_order_cart" class="btnCelcart" title="Thanh toán" href="index.php"></a>
							
                        </div>
                        <div class="phan2">
                        	<span>BÁN HÀNG ONLINE</span>
                        </div>
						<div class="phan3">
							<div class="phan31">
								<img src="img1/ym.png" >
							</div>
							<div class="phan32">
								<img src="img1/skype.png" >
							</div>
							<div class="phan33">
								Hotline: <font class="sdt">01675627444 </font>
							</div>
						</div>
						<div class="phan4">
							SÁCH MỚI
						</div>
					<?php if($sach_moi) foreach ($sach_moi as $newbook){?>
						<div class="phan5">
							<div class="phan51">
							<?php // $SalePrice= $newbook["SalePrice"]*1; echo $SalePrice; echo number_format($SalePrice, 0, ',', ' '); ?>
								<img src="img1/<?php  echo $newbook["ImgCover"]?>" width=70, height=70>
							</div>
							<div class="tieu-de"><a title=" <?php  echo $newbook["Name"]?> "href="<?php  echo $newbook["Link"]?> ?id=<?php  echo $newbook["idBook"]?> "><?php  echo $newbook["Name"]?><br/></a></div>
							Tắc giả: <a class="color1" title="More about Joe Vitale" href="#"><?php  echo $newbook["Author"]?></a> <br/>
							<div id="cang-ching-gia-ban">Giá bán: <span class="gia-ban"><?php if($newbook ["SalePrice"]>0){ echo number_format($newbook ["SalePrice"]*1, 0, ',', ' '); }  ?></span> </div>
							
									
						</div><!--end phan5-->
					<?php } ?>	
						
						<div class="phan6">
							<a class="xem-them" title="Tất cả" href="#"></a>
						
						</div><!--end phan6-->
						
						<div class="sach-doc-nhieu-nhat">
							SÁCH ĐỌC NHIỀU NHẤT
						</div>
						<?php if($sach_doc_nhieu) foreach ($sach_doc_nhieu as $readbooks){?>
						<div class="phan5">
							<div class="phan51">
								<img src="img1/<?php  echo $readbooks["ImgCover"]?>" width=70, height=70>
							</div>
							<div class="phan52">
								<div class="tieu-de"><a style ="font-size:11px;" title="<?php  echo $readbooks["Name"]?>" href="<?php  echo $readbooks["Link"]?>?id=<?php  echo $readbooks["idBook"]?>"><?php  echo $readbooks["Name"]?><br/></a></div>
								Tắc giả: <a class="color1" title="More about Joe Vitale" href="#"><?php  echo $readbooks["Author"]?></a> <br/>
								<div id="cang-ching-gia-ban">Giá bán: <span class="gia-ban"><?php if($readbooks ["SalePrice"]>0){ echo number_format($readbooks ["SalePrice"]*1, 0, ',', ' '); }  ?></span></div>
							</div>
						
						</div><!--end phan5-->
						
						<?php } ?>	
						
					
						<div class="phan6">
							<a class="xem-them" title="Tất cả" href="#"></a>
						</div><!--end phan6-->
						<div class="phan7"></div>
